home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Development
/
Source
/
PlainText
/
PlainText Worksheet
< prev
next >
Wrap
Text File
|
1994-02-03
|
15KB
|
306 lines
;----------------------------------------------------------------------------
; Worksheet
;
; Use this window as a scratch pad for keeping notes and as a space for
; temporary and intermediate work. Its contents are saved between launches
; of the PlainText program. If you don't like the idea of having a work-
; that is always open, select the "No Worksheet" option in the Edit Menu.
;
; Mel Park, Memphis, Tennessee
;----------------------------------------------------------------------------
This is the first non-beta version of PlainText. All major features
work, and seem to work well, on the machines I and others have tested
them on.
You should make a copy of this file and save it somewhere with a
different name. One way of doing this is to select the “Save a Copy”
item from the File Menu. Name the copy “Original PlainText Worksheet” or
some such.
File Menu
This is standard Mac stuff. PlainText will open any text file. Printing
is pretty ordinary. There is no way to change print margins or lines per
page. PlainText does print the page number at the bottom of each page. If
you hold the option key down while selecting the Open menu item, then all
files, not just text files, are displayed and can be opened. Files opened
in this way are read only. You can copy data from them to the clipboard but
not change them in any way.
The “Save” menu item is only activated when a file has been changed
by adding or removing characters. The term “dirty” is commonly used to
describe text files in this state. Non-editing changes, such as changing
the font or adding a mark do not dirty a file. However, all such changes,
even scroll position and selection range, are always saved to disk when
you close a file. So, don’t be surprised by disk activity when you close
a file in which you made no changes.
Edit Menu
Shift Right and Shift Left add or remove one tab on each line or,
when word wrap is in, each paragraph within the selection region. At the
same time, it converts all space runs to the corresponding number of tabs.
“Align” aligns all subsequent lines to the first line in the selection
region.
Check out the Undo function. It really works like it should. “No
Worksheet” will close the worksheet window and set PlainText to not open a
worksheet window in the future. It is reversed by the “Use Worksheet” menu
item which becomes an option when there is no worksheet. The Format dialog
of the Edit Menu is where you select fonts and font size, turn word-
wrapping on or off (on is the default), select tab width, and show or not
show invisible characters. These settings are remembered for each document
and retained between launches. (Naturally, this is a Mac.)
The “Show Invisibles” check box prints ‘¿’ for all non-printing
characters, ‘Δ’ for tabs, ‘¬’ for carriage returns, and ‘◊’ for spaces.
Find Menu
This all works. “Find…” and “Replace…” are pretty standard and pretty
intuitive functions for text windows. The search string can be a selection
expression, that is, an expression that contains wildcards. Try a search
using *menu as the selection expression. Choose “Find…” and type “*menu”
(with or without quotes) and click the “Selection Expression” radio button.
Now click the Find button (or hit the return key). See how a line containing
“menu” has been found? Command-G repeats the search.
If the selection expression is a number, it is interpreted as a line
number. Try 67 as a selection expression.
This line, the 67th in this window, will be selected.
If you hold down the shift key when you choose any of the Find menu
items, then the search will be in the reverse direction. This is handiest
when used in conjunction with the keyboard equivalents command-h and
command-g.
Mark Menu
Marks are like bookmarks that you can place in a text file so that you
can recall previous selections. When you select a mark from the Mark Menu,
the text corresponding to that mark is selected and the window scrolls to
show it. You can add new marks with the Mark menu item and remove them with
Unmark. You can alphabetize the order in which marks are displayed in the
Mark Menu by selecting the Alphabetize menu item. Selecting it again
restores the original order. Look at the Marks that I have made for this
file by opening the Marks Menu.
Window Menu
Stack and Tile windows work, as does the rest, a catalog of open
windows. The menu item for the front window is checked. The target window
is indicated by the bullet symbol (•). Windows whose changes have not
yet been saved to disk are underlined.
Convert Menu
These functions all work. If you spot bugs in them, be sure to let
me know. This set of functions, by the way, was selected from those I
find myself using many times a day in Vantage, the desk accessory editor
I have used for years. The big, full-featured editors, like Pete Keleher’s
Alpha and BBEdit, by Rich Siegel, have these features, plus many more, as
well. Strip Linefeeds is the way to convert an MS/DOS text file to the
Mac convention. Form Paragraphs and Straight to Curly Quotes gets it ready
for pasting into a word processor. Hard Wrap to Window and Curly to Straight
quotes reverses those steps, as when you want to prepare text for e-mail.
Both Hard Wrap functions insert hard carriage returns at line ends, where
a line end is either defined by the size of the window (Hard Wrap to Window)
of the line length parameter set in the Format Dialog (Hard Wrap to Length).
Besides being fast and able to handle even very large files, PlainText
has these built-in features:
1. Double-clicking selects a whole word. Note that double-clicking
the space after a word selects the preceeding word and the space.
This is a bug that is close enough to being a feature that I am
not fixing it.
2. Triple-clicking selects a whole line.
3. Double clicking on or just before a bracket or parenthesis (i.e.
“[”, “{”, etc.) causes all the text between the bracket or
parenthesis and its matching bracket or parenthesis to become
selected.
4. Cutting, pasting, and undoing are fully implemented.
5. The arrow keys work to move the insertion point or selection (hold
the shift key down) in the expected ways.
6. Command-option-uparrow moves the insertion point to the top of the
file. Command-option-downarrow does the opposite. Holding the shift
key down while doing either of these extends the selection to either
the top or bottom of the document.
7. Command-right arrow moves the insertion point to the end of the
current line. Option-right arrow moves the cursor by words. The left
arrow combinations work in the same way, of course, and holding the
shift key down with any of these combinations extends the selection.
This is the standard Macintosh use of the arrow keys.
8. It is a command-line interpreter in its own right. Simply type a
command that PlainText understands and then hit the enter (not
return) key. This will work in any text window.
The following commands can be executed from any text window:
ls (same as dir in DOS), cd (change directory), open, target,
find, line. Open opens the named file and makes it the front window.
File is similar except the window is made the target window (second
from front). “line n” selects selects the nth line of the target
window (n is a number. “Find exp” searchs the target window for the
string “exp.” Wildcards can be used with the find and ls commands,
just as you would expect in DOS.
In summary, hitting the enter key causes the current line or current
selection, whichever is smaller, to be interpreted as a command line.
Commands implemented:
cd Change default directory (folder). Note, the Mac
file system uses the colon to designate the present
or higher folders. Thus “cd ::” changes the default
directory one level up.
file Open a file and make it the target
find ss Find a string in the target window
ls List a directory’s contents
ls -l Give a full listing of a directory’s contents
line nn Select line nn in the target window
open ff Open a file
Target Window
Note that the “line” and “find” comands operate on the TARGET window.
The target window is the window behind the front-most window.
Large Files
PlainText must load it’s text files entirely into memory. If you get
an out-of-memory error message when trying to open a very large file, just
increase the partition (in the Finder’s Get-Info box for PlainText) to be
larger than the file being opened. In System 7, turn on virtual memory
if necessary.
Bug Reports
Send comments and complaints to:
Mel Park
Associate Professor
Department of Anatomy and Neurobiology
University of Tennessee
855 Monroe Avenue
Memphis, TN 38163
(901) 448-5984
mpark@utmem1.utmem.edu
PlainText is free.
Revision History
0.4: Fixed Standard File System 6 incompatibilities.
0.5: Wordwrap is now the default.
Horizontal scroll bar occurs when it should.
Wordwrap to window correctly updates window.
Fixed Out of Memory problem with add linefeeds.
0.6: Worksheet is an option.
Added font scaling and changing.
Open, file, and line commands now work in System 6.
All text moved to resources so that PlainText can now be
internationalized.
0.7: Added Aligh, Shift Left, and Shift Right functions.
Fixed bug in which a strings just past the cursor were not
found in a forward search.
Open with option key down shows all files, not just text
files.
0.8: SaveAFile stores resources properly and no longer causes
crashes.
The Standard File dialog is no longer displayed twice for new
files.
Typing no longer overwrites the horizontal scroll bar.
Fixed some minor annoyances in v. 0.8a, like new windows coming
up with the wrong horizonal scroll bar and the cursor not being
erased when a window is deselected.
0.9: There were bad crashes after some combinations of “Returns to
Linefeeds” and Saves or Closes, due to an old bug in the Mac
Menu Manager. Fixed now.
Similar bug was causing the Edit Menu to disappear when “No
Worksheet” was selected.
Worksheet and non-worksheet windows open with or without a
Go-Away Box as they should.
Added partial support for extended keyboard (Undo, cut, paste,
copy, page up, page down).
In System 7, opening from the finder directs Standard File package
to proper directory.
Horizonal arrow keys work properly except anchor point not yet
implemented.
0.91: Extended keyboard fully implemented.
Fixed crashes due to Menu Manager bug.
1.0: Added entab and detab functions.
Added word wrap to line lengths
Added autoindent
These last required additions to Format dialog.
Horizontal arrow keys now have an anchor point.
Word wrap to window is default for foreign text files as well
as new ones.
Command-arrow key functions now update the scroll bars.
Fixed conditions that would could cause a window to forget
that it was dirty, with subsequent loss of most-recently
typed data.
Text inserted at end of a line now drawn properly.
Errors in calculating buffer length in this last condition
also fixed.
Blinking cursor no longer interferes with text.
Show Invisibles with proportional fonts now works properly.
Go-Away box appears when it should in all conditions.
Fixed System 6 bugs--can now open from finder.
Hiliting of selection range is now always in the right place.
Inserting text beginning with a carriage return used to foul up
the line starts array. This could cause a crash.
Crashes related to marks and selections beyond the text buffer
fixed.
1.1: Fixed crashes due to errors in writing resources.
This means that resource forks are no longer corrupted.
Word wrap to length now works for newly opened documents.
Marks stopped working in v.1.0. Fixed.
Text now updated after Tile or Stack Windows.
Scroll bars now properly hilited after Tile and Stack Windows.
1.2: Format and date in ls -l command now correct.
Searches for Entire Word now work.
All Clipboard window deficiencies fixed, i.e. it is now updated
as it should be after cuts and copies, Menus are properly
updated when this is the selected window, and the blinking
cursor is disabled.
In large files, the blinking cursor would be displayed as a long
vertical line when the window was scrolled more than 32K pixels
beyond the insertion point. Fixed.
Line length default really set to 75. This means that the “Word
Wrap to Length” menu item works from the very beginning.
Implemented “Revert to Saved.”
Fixed scrolling error when large blocks of text deleted.
1.2a: When word wrap is on, Autoindent indents paragraphs, not lines.
PlainText will now open documents on locked volumes.
Saving now always flushes files to disk with every Save, even if
it is a sleeping PowerBook disk.
Tile and Stack Windows now work properly when there is no
worksheet.
No longer asks to save a saved new document when quitting.
Short lines nolonger pirate* the up and down arrow key cursor
movements.
Shift and align improved to work on word-wrapped paragraphs.
1.2b: Marks now aligned after pasting text.
Will now print beyond 32K of text.
1.2c: Marks now updated after large selections of text deleted.
Will now print invisible characters and tabs.
1.2d: Added page numbers to printed page.
1.2.1: First non-beta release to public servers, i.e. Info-Mac.
Restored “File open in another application” alert.
In word wrap, adding or deleting text that caused rewrapping of
paragraphs with more than 32 lines used to blank part of the
window above the changed text. Fixed.
Known bugs
Marks are not properly updated after entab and detab functions.
Marks sometimes not updated properly during normal editing. (Probably
fixed in v.1.2b.)
Features to be added:
Searching for carriage returns and other special characters.
More flexible saving of preferences.
Compile in PowerPC native mode.
Thanks to Florin Neumann, Robert J. Rockefeller, Bruce Craven, Ralph
Muha, Michael O’Henly, Ted Ripberger, Rich Siegel, Scott Gruby, and
particularly to Rich Scarlet for their many helpful comments.
------------
* Geo-speak. A stream is pirated when its flow is diverted into a
neighboring water course.